package jjn.acwing.algorithm_basic.chapter1.difference;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @author Jiang Jining
 * @since 2023-09-22 20:24
 */
public class Acwing798 {
    public static void main(String[] args) throws IOException {
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        String line = bufferedReader.readLine();
        int n, m, q;
        String[] parts = line.split(" ");
        n = Integer.parseInt(parts[0]);
        m = Integer.parseInt(parts[1]);
        q = Integer.parseInt(parts[2]);
        int[][] a = new int[n + 1][m + 1];
        int[][] prefix = new int[n + 2][m + 2];
        for (int i = 1; i <= n; i++) {
            String readLine = bufferedReader.readLine();
            String[] pairs = readLine.split(" ");
            for (int j = 1; j <= m; j++) {
                a[i][j] = Integer.parseInt(pairs[j - 1]);
            }
        }
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                insert(prefix, i, j, i, j, a[i][j]);
            }
        }
        while (q-- > 0) {
            String input = bufferedReader.readLine();
            String[] nums = input.split(" ");
            int x1 = Integer.parseInt(nums[0]);
            int y1 = Integer.parseInt(nums[1]);
            int x2 = Integer.parseInt(nums[2]);
            int y2 = Integer.parseInt(nums[3]);
            int k = Integer.parseInt(nums[4]);
            insert(prefix, x1, y1, x2, y2, k);
        }
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                prefix[i][j] += prefix[i][j - 1] + prefix[i - 1][j] - prefix[i - 1][j - 1];
                System.out.print(prefix[i][j] + " ");
            }
            System.out.println();
        }
        bufferedReader.close();
    }
    
    public static void insert(int[][] a, int x1, int y1, int x2, int y2, int c) {
        a[x1][y1] += c;
        a[x2 + 1][y1] -= c;
        a[x1][y2 + 1] -= c;
        a[x2 + 1][y2 + 1] += c;
    }
}
